#include "coutputaudiostream.h"

namespace buola { namespace media { namespace ffmpeg {

COutputAudioStream::COutputAudioStream(AVFormatContext* pCtx, const std::string& pCodec)
{
    AVCodec *lCodec=avcodec_find_encoder_by_name(pCodec.c_str());
    
    mAV=avformat_new_stream(pCtx,lCodec);
    mAV->id=pCtx->nb_streams-1;
    
    if(pCtx->oformat->flags&AVFMT_GLOBALHEADER)
        mAV->codec->flags|=CODEC_FLAG_GLOBAL_HEADER;

    //some parameters should probably be set here

    int lRet=avcodec_open2(mAV->codec,lCodec,nullptr);
    if(lRet<0) throw XInvalid("could not open audio codec");
    
    //we should create buffers at some point
}

/*namespace ffmpeg*/ } /*namespace media*/ } /*namespace buola*/ }
